<?php
require 'Admin/Controller/Controller.php ';
require 'Admin/Model/CartoonModel.php';
class CartoonController extends Controller{
	function __Construct(){
		parent::__Construct();
		//$this->mod = 'cartoons';
/*function redirect($url, $msg)
{     
   echo $msg.'<a href="'.$url.'">急死你</a>';
   header("refresh:1;url=$url"); 
}*/
	}
	function index(){
		$model = new CartoonModel();
		$data = $model->getCartoonList();
		$this->assign('cartoon',$data);
		$this->display(); 

	}
	function form(){
		$this->display();
	}
	function add(){

		$data=$_POST;
		$model=new CartoonModel();
		$re=$model->addCartoon($data);
         if($re)
    {
     /*echo "success";
            echo '<a href=admin.php?c=cartoon&m=index>返回</a>';*/
            redirect('admin.php?c=cartoon&m=index', '添加成功！');  
     }
     else
     {  redirect('admin.php?c=cartoon&m=form', '添加失败！');  
    }
      
	}
	function del(){
		$id=$_GET['id'];
     	$mod=new cartoonModel();
     	$data=$mod->Delcartoon($id);
     	 if($data)
    {
     /*echo "success";
            echo '<a href=admin.php?c=cartoon&m=index>返回</a>';*/
            redirect('admin.php?c=cartoon&m=index', '删除成功！');  
     }
     else
     {
      
                   redirect('admin.php?c=cartoon&m=index', '删除失败！');  
    }
	}
	function mod(){
	    $id=$_GET['id'];
        //var_dump($id);
        $model=new cartoonmodel();
        $re=$model->getCartoonByID($id);
      require'admin/view/cartoon/mod.php';
       /*$this->assign('cartoon',$re);
       $this->display();*/
	}
	function update(){

       $data=$_POST;
     	var_dump($data);
     	//exit;
     	$id=$_GET['id'];
     	$mod=new cartoonmodel();
     	$result=$mod->Updatecartoon($id);
     	if ($result)
            {

 redirect('admin.php?c=user&m=display', '修改成功！');  
 
           	/*echo "success";
           	echo '<a href=admin.php?c=cartoon&m=index>返回</a>';*/
           }
        	else
        	{
        			redirect('admin.php?c=user&m=display', '修改失败！');  
 
        	}
	}

function search(){
$key=$_POST['key'];
    $data = $this->model->search($key);
	}
    function search1(){
        $key=$_POST['key'];
        $model=new CartoonModel();
        $data=$model->search1($key);
        //var_dump($data);
        require 'admin/view/cartoon/search.php';

    }

}
?>